﻿package mortal.game.view.copy.expCopy
{
    import Message.Game.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;

    public class ExpCopyCache extends Object
    {
        private var _myExpCopyInfo:SMyExpCopyInfo;

        public function ExpCopyCache()
        {
            return;
        }// end function

        public function set myExpCopyInfo(param1:SMyExpCopyInfo) : void
        {
            this._myExpCopyInfo = param1;
            return;
        }// end function

        public function get myExpCopyInfo() : SMyExpCopyInfo
        {
            return this._myExpCopyInfo;
        }// end function

        public function getExpCopyInfoByDay(param1:int) : STodayExpCopyInfo
        {
            var _loc_2:STodayExpCopyInfo = null;
            var _loc_3:Array = null;
            var _loc_4:STodayExpCopyInfo = null;
            if (this._myExpCopyInfo)
            {
                _loc_3 = this._myExpCopyInfo.expInfos;
                for each (_loc_4 in _loc_3)
                {
                    
                    if (_loc_4.openDays == param1)
                    {
                        _loc_2 = _loc_4;
                        break;
                    }
                }
            }
            return _loc_2;
        }// end function

        public function get isCanEnterExpCopy() : Boolean
        {
            var _loc_1:Boolean = false;
            var _loc_2:int = 0;
            var _loc_3:STodayExpCopyInfo = null;
            var _loc_4:int = 0;
            if (this._myExpCopyInfo)
            {
                _loc_2 = ClockManager.instance.serverOpenDateNum;
                _loc_3 = this.getExpCopyInfoByDay(_loc_2);
                if (_loc_3 == null)
                {
                    _loc_1 = true;
                }
                else
                {
                    _loc_4 = Cache.instance.pack.backPackCache.getItemCountByItemCode(GameConst.TConstExpCopyItemCode, true);
                    if (_loc_4 > 0)
                    {
                        _loc_1 = true;
                    }
                }
            }
            return _loc_1;
        }// end function

        public function get canEnterCopyNum() : int
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:int = 0;
            var _loc_4:STodayExpCopyInfo = null;
            var _loc_5:int = 0;
            if (this._myExpCopyInfo)
            {
                _loc_3 = ClockManager.instance.serverOpenDateNum;
                _loc_4 = this.getExpCopyInfoByDay(_loc_3);
                if (_loc_4 == null)
                {
                    _loc_1++;
                }
                else
                {
                    _loc_2 = _loc_4.enterTimes;
                }
                _loc_5 = Cache.instance.pack.backPackCache.getItemCountByItemCode(GameConst.TConstExpCopyItemCode, true);
                _loc_1 = _loc_1 + _loc_5;
            }
            _loc_1 = _loc_1 > 6 - _loc_2 ? (6 - _loc_2) : (_loc_1);
            return _loc_1;
        }// end function

    }
}
